package com.jindy.module.rushBaseView.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.module.rushBaseView.domain.RushBaseViewSearchVO;
import com.jindy.module.rushBaseView.domain.RushBaseViewVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.rushBaseView.domain.RushBaseView;
import com.jindy.module.rushBaseView.service.IRushBaseViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 催收基表Controller
 * 
 * @author jindy
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/module/rushBaseView")
public class RushBaseViewController extends BaseController
{
    @Autowired
    private IRushBaseViewService rushBaseViewService;

    /**
     * 查询催收基表列表
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody RushBaseViewSearchVO rushBaseViewSearchVO)
    {
        startPage();
        List<RushBaseViewVO> list = rushBaseViewService.selectRushBaseViewList(rushBaseViewSearchVO);
        return getDataTable(list);
    }

    /**
     * 导出催收基表列表
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:export')")
    @Log(title = "催收基表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RushBaseViewSearchVO rushBaseViewSearchVO)
    {
        List<RushBaseViewVO> list = rushBaseViewService.selectRushBaseViewList(rushBaseViewSearchVO);
        ExcelUtil<RushBaseViewVO> util = new ExcelUtil<RushBaseViewVO>(RushBaseViewVO.class);
        util.exportExcel(response, list, "催收基表数据");
    }

    /**
     * 获取催收基表详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:query')")
    @GetMapping(value = "/{logisticsTime}")
    public AjaxResult getInfo(@PathVariable("logisticsTime") String logisticsTime)
    {
        return AjaxResult.success(rushBaseViewService.selectRushBaseViewByLogisticsTime(logisticsTime));
    }

    /**
     * 新增催收基表
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:add')")
    @Log(title = "催收基表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RushBaseView rushBaseView)
    {
        return toAjax(rushBaseViewService.insertRushBaseView(rushBaseView));
    }

    /**
     * 修改催收基表
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:edit')")
    @Log(title = "催收基表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RushBaseView rushBaseView)
    {
        return toAjax(rushBaseViewService.updateRushBaseView(rushBaseView));
    }

    /**
     * 删除催收基表
     */
    @PreAuthorize("@ss.hasPermi('module:rushBaseView:remove')")
    @Log(title = "催收基表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logisticsTimes}")
    public AjaxResult remove(@PathVariable String[] logisticsTimes)
    {
        return toAjax(rushBaseViewService.deleteRushBaseViewByLogisticsTimes(logisticsTimes));
    }
}
